function submitPoll(){
  var selected = $('input[type=radio]:checked').val();
  //alert(root); return false;

  $.post(root + 'vi/polls_answer/answer_polls', {id:selected}, function(data){
      alert('Thanks for your submitted!');
    }
  );

}

function reCaptcha(){
  $.post(root+'vi/home/reCaptcha','',function(response){
      $('#captcha-img img:eq(0)').replaceWith(response);
  });
}

function EnterLogin(a){
  if(a.keyCode==13){
    login()
  }
}

//login
function login(){
  url = $('#loginForm').attr('action');
  data = $('#loginForm').serialize();
  $.post(
      url,
      data,
      function(response){
        if(response == 'incorrect_captcha'){
          alert('Captcha incorrect !');
          return false;
        }
        else if(response == 1){
          //success
          location.href = root;
        }
        else{
          alert('Username or password incorrect!');
          return false;
        }
      }
    );
}

$(document).ready(function(){
	if($('a.popup_mail_click').length > 0){
		$('a.popup_mail_click').fancybox({
			padding: 20,
			titleShow: false
		});
	}
	
	if($('#slider').length > 0){
		$('#slider').nivoSlider({
			effect: 'random',
			slices: 20,
			animSpeed: 1000,
			controlNav: false,
			directionNav: false
		});
	}
});
